Skip to content
This repository was archived by the owner on Jun 10, 2020. It is now read-only.

Include EventId in telemetry properties#570

Merged
cijothomas merged 10 commits intomicrosoft:developfrom
duracellko:eventid
Mar 8, 2018
Merged

Include EventId in telemetry properties#570
cijothomas merged 10 commits intomicrosoft:developfrom
duracellko:eventid

Conversation

@duracellko
Copy link
Copy Markdown
Contributor

Fix issue #569.

Main update is to ApplicationInsightsLogger. It includes EventId and EventName properties in telemetry. It is included only, when EventId has non-default values.
By default this functionality is off for compatibility. Following example can switch it on:
This code should be ASP.NET Core application Startup class.

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    services.Configure<ApplicationInsightsLoggerOptions>(Configuration.GetSection("ApplicationInsights"));
    services.AddLogging(logging =>
        {
            logging.AddConfiguration(Configuration.GetSection("Logging"))
                .AddConsole()
                .AddDebug();
            logging.Services.TryAddEnumerable(ServiceDescriptor.Singleton<ILoggerProvider, ApplicationInsightsLoggerProvider>());
        });
}

Additionally test coverage of ApplicationInsightsLogger was improved.

@duracellko duracellko changed the title Eventid Include EventId in telemetry properties Dec 12, 2017
@cijothomas
Copy link
Copy Markdown
Contributor

@duracellko Thanks for your contribution!
We are currently fixing some issues related to symbols, and the next beta release.
Will look at this and merge as soon as the next beta is released.
Thanks!

@cijothomas
Copy link
Copy Markdown
Contributor

@duracellko Thanks for your patience! (I assure nobody will have to wait months for a PR review going forward)
I will review this now and merge after comments are addressed.

Copy link
Copy Markdown
Contributor

@cijothomas cijothomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of changes requested.
I'd prefer to see the same approach used in the other PR I have mentioned about passing ApplicationInsightsLoggerOptions to both ApplicationInsightsLogger and Provider.

CHANGELOG.md Outdated
- Live metrics collection is enabled by default for .NET Core applications (was already enabled for full .NET applications).
- Updated Web/Base SDK version dependency to 2.5.0-beta1.
- DependencyCollector referred from 2.5.0-beta1 supports collecting SQL dependency calls in .NET Core Applications using EntityFramework.
- ApplicationInsightsLogger adds EventId into telemetry properties. It is off by default for compatibility. It can be switched on by configuring ApplicationInsightsLoggerOptions.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this to 2.3.0-beta1 please?

public ApplicationInsightsLoggerProvider(TelemetryClient telemetryClient, IOptions<ApplicationInsightsLoggerOptions> options)
{
this.telemetryClient = telemetryClient;
this.filter = trueFilter;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use a true filter here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I followed pattern in ConsoleWriter, but it is not needed with new approach.

/// <summary>
/// Options for configuration of <see cref="ApplicationInsightsLogger"/>.
/// </summary>
public class ApplicationInsightsLoggerOptions
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another PR which introduces ApplicationInsightsLoggerOptions
https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/574/files
Can you also have took at that as well?

I think passing ApplicationInsightsLoggerOptions to both ApplicationInsightsLoggerProvider and ApplicationInsightsLogger as done in the other PR is a better option. Can you incorporate this change to your PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the hint. Yes, it's actually better. Also I realized that classes are internal, so I can change signature of constructors.

Assert.True(isCorrectVersion);
}

/// <summary>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for adding sufficient unit tests!

@duracellko
Copy link
Copy Markdown
Contributor Author

Thank you for comments. I will have a look at those later this week.

@cijothomas cijothomas closed this Mar 8, 2018
@cijothomas cijothomas reopened this Mar 8, 2018
@cijothomas cijothomas closed this Mar 8, 2018
@cijothomas cijothomas reopened this Mar 8, 2018
@cijothomas cijothomas merged commit 725a7bd into microsoft:develop Mar 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants